package com.sbj.controller;

import cn.hutool.core.convert.Convert;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.sbj.dto.req.CouponsReq;
import com.sbj.dto.res.CouponsRes;
import com.sbj.entity.Coupons;
import com.sbj.service.ICouponsService;
import com.zmh.framework.config.BaseCommonInterface;
import com.zmh.framework.util.Result;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RestController;

import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author summer
 * @since 2024/08/10 10:02:40
 */
@RestController
@RequestMapping("/coupons")
@AllArgsConstructor
public class CouponsController implements BaseCommonInterface<CouponsReq, CouponsRes> {

    private final ICouponsService couponsService;

    @Override
    public Result<String> save(@Valid CouponsReq couponsReq) {
        Coupons convert = Convert.convert(Coupons.class, couponsReq);
        couponsService.saveOrUpdate(convert);
        return Result.successResult();
    }


    @Override
    public Result<String> del(Integer id) {
        couponsService.removeById(id);
        return Result.successResult();
    }

    @Override
    public Result<Page<CouponsRes>> lists(CouponsReq couponsReq) {
        return Result.successResult(couponsService.lists(couponsReq));
    }

    @Override
    public Result<CouponsRes> findById(Integer integer) {
        return null;
    }

    @Override
    public Result<String> batchDel(List<CouponsRes> list) {
        return null;
    }
}
